Trading Sequence Diagrams

The workflow for several of the trading processes between the client UI application and the GAIN Capital trading services are shown in the following annotated sequence diagrams. The diagrams illustrate the general flow of calls and responses for the C# library and client UI during trading processes such as placing a trade, creating an entry order, or account login. The annotations for the diagram present additional information about the process.

Login & Retrieve Account Information

Notes

Login to the trading account and retrieve the account information:

 

  1. Perform account login by calling

    CiApi.Instance.Login(username, password, tradingApiBaseUri);

     

  2. When login is successful, retrieve the account information as follows

    AccountInformationResponseDTO accountInfoResponse = CiApi.Instance.ServiceManager.AccountInformationService.GetClientAndTradingAccount()

 

Market Search to Populate a Market Grid

The following sequence shows the process flow to return all FX markets to the user, as an example to populate a market grid with constantly updating prices.

Notes

Populate the market grid and subscribe to price streams to update the grid appropriately:

  1. The following market search returns all FX markets for the user account

    IList<ApiMarketDTO> apiMarketDtoList = CiApi.Instance.ServiceManager

    .CfdMarketService.ListCfdMarkets("", true, true, accountInfoResponse.ClientAccountId, 70).Markets;

  2.  

  3. Read the markets returned from the search into a list

    List<int> marketIdList = apiMarketDtoList.Select(apiMarketDTO => apiMarketDTO.MarketId).ToList();

  4.  

  5. Retrieve the market information for each of the FX markets

    ListMarketInformationResponseDTO listMarketInformationResponseDTO = ciApi.ServiceManager.MarketInformationService.ListMarketInformation(marketIdList);

     

  6. Preparation for Lightstreamer subscription

    CiApi.Instance.StreamingManager.StreamingUrl = lightStreamerUrl;

     

  7. Subscribe to price stream

    CiApi.Instance.StreamingManager.Streams.PriceStream.SubscribeToMarketPriceList(marketIdList);

 

If required to mock the CiApi, inject the instance into your client class, otherwise, you substitute _ciApi for CiApi.Instance. For example,

public MarketGridViewModel(ICiApi ciApi)

{

_ciApi = ciApi;

}